<?php

namespace App\Models;

use App\Models\traits\serializeDate;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Sanctum\HasApiTokens;

class Wxuser extends Authenticatable
{
    use HasApiTokens, serializeDate;

//声明guard_name
    protected $guard_name = ['sanctum'];
    protected $hidden = ['pivot'];
    protected $table = 'wxusers';


    public $guarded = [];

    //中间表多对多，自己作为村管理员与村关联
    public function villages()
    {
        return $this->belongsToMany(Village::class, 'admin_village')->withTimestamps();
    }


    // 关联投诉(作为管理员)
    public function replyReports()
    {
        return $this->morphMany(Report::class, 'reportable');
    }

    // 关联诉求表(作为管理员)
    public function replyAppeals()
    {
        return $this->morphMany(Appeal::class, 'appealable');
    }

    // 关联政策咨询(作为管理员)
    public function replyConsultations()
    {
        return $this->morphMany(Consultation::class, 'consultationable');
    }

    //关联政策咨询(作为村民)
    public function consultations()
    {
        return $this->hasMany(Consultation::class);
    }

    //关联反应诉求(作为村民)
    public function appeals()
    {
        return $this->hasMany(Appeal::class);
    }

    //关联举报干部(作为村民)
    public function reports()
    {
        return $this->hasMany(Report::class);
    }
}
